function initCurrentDateData(data){
	var date=new Date();
	var currentDate=date.getDate();

	for(var i=0;i<data.length;i++){
		var dataItem=data[i];
		if(dataItem.date==currentDate){

			currentDateData.sumDealMoney=parseInt(dataItem.sumDealMoney);
			currentDateData.sumOrderQuantity=parseInt(dataItem.sumOrderQuantity);
			break;
		}
	}
}

function initCurrentMonthData(data){
	var date=new Date();
	var currentMonth=date.getMonth()+1;
	for(var i=0;i<data.length;i++){
		var dataItem=data[i];
		if(dataItem.month==currentMonth){
			currentMonthData.sumDealMoney=parseInt(dataItem.sumDealMoney);
			currentMonthData.sumOrderQuantity=parseInt(dataItem.sumOrderQuantity);
			break;
		}
	}
}

function initOrderInfo(data){
	var currentDateStr=getCurrentDateStr();
			
	for(var i=0;i<data.length;i++){
		var dataItem=data[i];
		var currentFormatTime= currentDateStr+" "+dataItem.createTime;
		var currentTimeStamp=transformToTimeStamp(currentFormatTime);
		
		var newDataItem={};
		newDataItem.timeStamp=currentTimeStamp;
		newDataItem.storeName=dataItem.storeName;
		newDataItem.totalMoney=parseInt(dataItem.totalMoney);
		newDataItem.createTime=dataItem.createTime
		orderInfo.push(newDataItem);
	}
	orderInfo.sort(function(a,b){
		return a.timeStamp-b.timeStamp;
	});
}

function setNoticeBoardVueData(){
		//scrollbarVue.list=orderInfo;
		
	//noticeBoardVue.show=false;
	
	var currentDateSumDealMoney=getCurrentDateSumDealMoney();
	noticeBoardVue.currentDateSumDealMoney=currentDateSumDealMoney;
	noticeBoardVue.currentMonthSumDealMoney=getCurrentMonthSumDealMoney(currentDateSumDealMoney);
	noticeBoardVue.currentYearSumDealMoney=getCurrentYearSumDealMoney(currentDateSumDealMoney);

	var currentDateSumOrderQuantity=getCurrentDateSumOrderQuantity();
	noticeBoardVue.currentDateSumOrderQuantity=currentDateSumOrderQuantity;
	noticeBoardVue.currentMonthSumOrderQuantity=getCurrentMonthSumOrderQuantity(currentDateSumOrderQuantity);
	noticeBoardVue.currentYearSumOrderQuantity=getCurrentYearSumOrderQuantity(currentDateSumOrderQuantity);
	
	/*setTimeout(function(){
        noticeBoardVue.show=true;
	},1000);*/

}



function setVueDataTimer(){
	setInterval(function(){
		var data=getData();
		if(data.length>0){
			addScrollbarData(data);
			setNoticeBoardVueData();
		}
	},requestTimeInterval*1000)
}



function getData(){
	var data=[];
	var currentTimeStamp=Date.parse(new Date());
	var startTimeStamp=currentTimeStamp-requestTimeInterval*1000;
	
	
	data=searchTimeStampRangeData(startTimeStamp,currentTimeStamp);
	
	return data;
}

function getCurrentDateStr(){
	var date=new Date();
	return date.getFullYear()+"/"+(date.getMonth()+1)+"/"+date.getDate();
}

function transformToTimeStamp(time){
	//time目标格式例子:'2017/04/18 09:16:15'
	
	return Date.parse(new Date(time));
}



function getCurrentMonthSumDealMoney(currentDateSumDealMoney){
	return currentDateSumDealMoney+currentDateData.sumDealMoney;
}

function getCurrentYearSumDealMoney(currentDateSumDealMoney){
	return currentDateSumDealMoney+currentDateData.sumDealMoney+currentMonthData.sumDealMoney;
}



function getCurrentMonthSumOrderQuantity(currentDateSumOrderQuantity){
	return currentDateSumOrderQuantity+currentDateData.sumOrderQuantity;
}

function getCurrentYearSumOrderQuantity(currentDateSumOrderQuantity){
	return currentDateSumOrderQuantity+currentDateData.sumOrderQuantity+currentMonthData.sumOrderQuantity;
}

function addScrollbarData(data){
	var historyData=scrollbarVue.list;
	var newData=data.concat(historyData);
	scrollbarVue.list=newData;
	
	scrollAnimation();
}

function removeScrollbarData(){
	scrollbarVue.list.splice(2,scrollbarVue.list.length-2);
}


function scrollAnimation(){
	var $scrollbarList=$("#scrollbar .list");
	var itemWidth=$scrollbarList.find(".item").width();
	var marginLeft=-(scrollbarVue.list.length-2)*itemWidth;
	$scrollbarList.css("marginLeft",marginLeft+"px");
	
	setTimeout(function(){
		$scrollbarList.css("transition","margin-left "+scrollTime+"s");
		//$scrollbarList.addClass("transition-Animation");
		$scrollbarList.css("marginLeft","0");
		
		setTimeout(function(){
			removeScrollbarData();
			$scrollbarList.css("transition","margin-left 0s");
			//$scrollbarList.removeClass("transition-Animation");
		},scrollTime*1000-100);
	},100); 
}